package org.ryan.timedstart;

import java.util.ArrayList;

import android.app.AlarmManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

public class BootUpReceiver extends BroadcastReceiver {

	public static final String ACTION = "org.ryan.START_21_DAYS";

	// public static final long ALARM_REPEAT =
	// public static final long ALARM_REPEAT = AlarmManager.INTERVAL_FIFTEEN_MINUTES / 7; // FIXME
	public static final long ALARM_REPEAT = AlarmManager.INTERVAL_DAY;

	public static ArrayList<Long> ats = new ArrayList<Long>();

	@Override
	public void onReceive(Context context, Intent intent) {
		if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
			Intent i = new Intent(context, ConfigActivity.class);
//			i.setAction(ConfigActivity.ACTION_BOOT_INIT);
			i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(i);
			return;

		}

		Toast.makeText(context,
				"BootUpReceiver bcast recved: " + intent.getAction(),
				Toast.LENGTH_LONG).show();

		if (ACTION.equals(intent.getAction())) {

			Intent newi = new Intent(Intent.ACTION_VIEW);
			newi.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			newi.setData(Uri.parse("http://173.230.140.200:10080/list.htm"));
			context.startActivity(newi);
		}
	}
}